import { NoSkinCellRenderer } from "../../common/item/NoSkinCellRenderer";
import { MagicWeaponItemData } from "../MagicWeaponItemData";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { Language } from "../../../../../extend/language/Language";
import { ObjCreate } from "../../common/ObjCreate";
import { GlobalClass } from "../../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../../resource/ImagesConst";
import { GlobalStyle } from "../../../../common/global/GlobalStyle";
import { BaseItem } from "../../common/BaseItem";
import { LoaderHelp } from "../../../../common/display/LoaderHelp";
import { ResFileConst } from "../../../resource/ResFileConst";
import { GTextFiled } from "../../../../../com/mui/controls/GTextFiled";
import { ScaleBitmap } from "../../../../../com/mui/display/ScaleBitmap";
//class IdentifyItemRenderer
    
    export  class IdentifyItemRenderer extends NoSkinCellRenderer
    {
        constructor()
        {
            super();
            setSize(76, 76);
            this.init();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1 as MagicWeaponItemData;
            if (loc1) 
            {
                this._baseItem.itemData = loc1.itemData;
                if (loc1.itemData) 
                {
                    if (loc1.itemData.isHasIdentify()) 
                    {
                        this.removeNoIdentifyBg();
                        this.addChildAt(this._hasIdentifyBg, 0);
                        this._gradeLabel.htmlText = HTMLUtil.addColor(Language.getStringByParam(27673, loc1.itemData.magicWeaponScore), "#ffff00");
                    }
                    else 
                    {
                        if (this._noIdentifyBg == null) 
                        {
                            this._noIdentifyBg = ObjCreate.createBg(0, 0, 56, 77);
                        }
                        this.removeHasIdentifyBg();
                        this.addChildAt(this._noIdentifyBg, 0);
                        this._gradeLabel.htmlText = HTMLUtil.addColor(Language.getString(27672), "#F54a4a");
                    }
                }
                else 
                {
                    this.removeHasIdentifyBg();
                    this.removeNoIdentifyBg();
                    this._gradeLabel.htmlText = "";
                }
            }
            return;
        }

        /* internal  */removeHasIdentifyBg(): void
        {
            if (this._hasIdentifyBg && this.contains(this._hasIdentifyBg)) 
            {
                this.removeChild(this._hasIdentifyBg);
            }
            return;
        }

        /* internal  */removeNoIdentifyBg(): void
        {
            if (this._noIdentifyBg && this.contains(this._noIdentifyBg)) 
            {
                this.removeChild(this._noIdentifyBg);
            }
            return;
        }

        /* internal  */onLoadResHandler(): void
        {
            this._hasIdentifyBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.IdentifyRendererBg);
            return;
        }

        /* internal  */init(): void
        {
            var loc1=ObjCreate.createBitmap(ImagesConst.AchievementIconBg, 5, 26, this);
            this._gradeLabel = ObjCreate.createGTextField("", 0, 3, 56, 25, this, GlobalStyle.getTextFormatCenter(GlobalStyle.textFormatWhite));
            this._baseItem = new BaseItem();
            this._baseItem.isShowLock = true;
            ObjCreate.setObjAttri(this._baseItem, 12, 32, 32, 32, this);
            this._hasIdentifyBg = new Object /* flash.display.Bitmap */();
            LoaderHelp.addResCallBack(ResFileConst.magicWeapon, this.onLoadResHandler);
            return;
        }

        /* internal */ /* var */_gradeLabel: GTextFiled;

        /* internal */ /* var */_baseItem: BaseItem;

        /* internal */ /* var */_hasIdentifyBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */_noIdentifyBg: ScaleBitmap;
    }
